load("@nazel//:nazel_build.bzl", "nazel_cc_binary", "nazel_cc_library")
load("@com_grail_bazel_compdb//:aspects.bzl", "compilation_database")

package(default_visibility = ["//visibility:public"])

nazel_cc_library(
    name = "coin2",
    srcs = glob(
        [
            "**/*.cc",
            "**/*.cpp",
        ],
        exclude = [
            "test/**/*.cc",
            "bench/**/*.cc",
        ],
    ),
    hdrs = glob(
        ["**/*.h"],
        exclude = [
            "test/**/*.h",
            "bench/**/*.h",
        ],
    ),
    copts = [
    ],
    defines = [
        "BOOST_COROUTINES_NO_DEPRECATION_WARNING",  # boost::asio::spawn only supports coroutine1
        "BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG",  # nanosecond support in boost::posix_time
        "DOCTEST_CONFIG_DISABLE",
        "DOCTEST_CONFIG_NO_SHORT_MACRO_NAMES",
        "OPENSSL_VERSION_3_0",
        "HAVE_SSL=1",  # ssl support in quickfix
        "BACKWARD_HAS_DW=1",
    ],
    linkopts = [
        "-pthread",
        "-lz",
        "-lssl",
        "-lcrypto",
        "-lstdc++fs",
        "-llz4",
        "-lcurl",
        "-lfmt",
        "-lhdf5",
        "-lboost_coroutine",
        "-lboost_date_time",
        "-lboost_system",
        "-lboost_filesystem",
        "-ldw",
        "-lzmqpp",
        "-lzip",
        "-ltreelite_runtime",
        "-lcryptopp",
        "-lmkl_core",
        "-lmkl_gnu_thread",
        "-lmkl_intel_lp64",
    ],
    deps = [
        "//cc/coin2/base",
        "//cc/coin2/base/math:time_moving_window",
        "//cc/coin2/base/request",
        "//cc/coin2/base/influxdb",
        "//cc/coin2/base/request/http2",
        "//cc/coin2/strategy/util:strat_util",
        "//cc/coin2/controller",
        "//cc/third_party:azmq",
        "//cc/third_party:highfive",
        "//cc/third_party:spdlog",
        "//cc/third_party:toml11",
        "//cc/third_party/doctest",
        "//cc/third_party/jwt-cpp",
        "//cc/third_party/simdjson",
        "//cc/third_party/span",
        "//cc/third_party/trompeloeil",
        "@apiset//coin/feed/fastfeed:fastfeed_cpp",
        "@apiset//coin/proto:coin_cpp",
        "@apiset//coin2:coin2_service_cpp",
        "@apiset//coin2:coin2_cpp",
        "@apiset//fastfeature:fastfeature_cpp",
        "@apiset//feedset:feedset_cpp",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/container:flat_hash_set",
        "@com_google_absl//absl/container:node_hash_map",
        "@com_google_absl//absl/container:node_hash_set",
        "@com_google_absl//absl/strings",
        "@com_github_jupp0r_prometheus_cpp//pull",
        "@fastfeature//fastfeature:fastfeature_prod",
        "@motion//orio",
        "@quickfix//quickfix",
        "@starkware",
        "@navi_third_party2//third_party/glog:glog",
        "@navi_third_party2//naviasync/appinfo:init",
        "@navi_third_party2//naviasync/ipc:coin_reactor",
        "@navi_third_party2//naviasraw/fix:fixmsg",
        "@navi_third_party2//naviasraw/fix:fix_sequencer",
        "@navi_third_party2//naviasraw/tcp/client:lws_client_conda",
    ],
)

nazel_cc_library(
    name = "coin2_with_doctest",
    srcs = glob(
        [
            "**/*.cc",
            "**/*.cpp",
        ],
        exclude = [
            "test/**/*.cc",
            "bench/**/*.cc",
        ],
    ),
    hdrs = glob(
        ["**/*.h"],
        exclude = [
            "test/**/*.h",
            "bench/**/*.h",
        ],
    ),
    defines = [
        "BOOST_COROUTINES_NO_DEPRECATION_WARNING",  # boost::asio::spawn only supports coroutine1
        "BOOST_DATE_TIME_POSIX_TIME_STD_CONFIG",  # nanosecond support in boost::posix_time
        "DOCTEST_CONFIG_NO_SHORT_MACRO_NAMES",
        "GOOGLE_STRIP_LOG=1",
        "OPENSSL_VERSION_3_0",
        "HAVE_SSL=1",  # ssl support in quickfix
    ],
    linkopts = [
        "-pthread",
        "-lz",
        "-lssl",
        "-lcrypto",
        "-lstdc++fs",
        "-llz4",
        "-lcurl",
        "-lfmt",
        "-lboost_coroutine",
        "-lboost_date_time",
        "-lboost_system",
        "-lboost_filesystem",
        "-ldw",
        "-lzmqpp",
        "-lzip",
        "-ltreelite_runtime",
        "-lmkl_core",
        "-lmkl_gnu_thread",
        "-lmkl_intel_lp64",
    ],
    deps = [
        "//cc/coin2/base",
        "//cc/coin2/base/influxdb",
        "//cc/coin2/base/math:time_moving_window",
        "//cc/coin2/base/request",
        "//cc/coin2/base/request/http2",
        "//cc/coin2/controller",
        "//cc/coin2/strategy/util:strat_util",
        "//cc/third_party/doctest",
        "//cc/third_party/fast_double_parser",
        "//cc/third_party/jwt-cpp",
        "//cc/third_party/simdjson",
        "//cc/third_party/span",
        "//cc/third_party/trompeloeil",
        "//cc/third_party:azmq",
        "//cc/third_party:highfive",
        "//cc/third_party:spdlog",
        "//cc/third_party:toml11",
        "@apiset//coin/feed/fastfeed:fastfeed_cpp",
        "@apiset//coin/proto:coin_cpp",
        "@apiset//coin2:coin2_service_cpp",
        "@apiset//coin2:coin2_cpp",
        "@apiset//fastfeature:fastfeature_cpp",
        "@apiset//feedset:feedset_cpp",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/container:flat_hash_set",
        "@com_google_absl//absl/container:node_hash_map",
        "@com_google_absl//absl/container:node_hash_set",
        "@com_google_absl//absl/strings",
        "@com_github_jupp0r_prometheus_cpp//pull",
        "@fastfeature//fastfeature:fastfeature_prod",
        "@motion//orio",
        "@quickfix//quickfix",
        "@starkware",
        "@navi_third_party2//third_party/glog:glog",
        "@navi_third_party2//naviasync/appinfo:init",
    ],
)

nazel_cc_binary(
    name = "test",
    srcs = glob(
        [
            "test/**/*.cc",
            "test/**/*.h",
        ],
    ),
    defines = [
        "DOCTEST_CONFIG_NO_SHORT_MACRO_NAMES",
        "GOOGLE_STRIP_LOG=1",
    ],
    linkopts = [
        "-lcryptopp",
        "-lmkl_core",
        "-lmkl_gnu_thread",
        "-lmkl_intel_lp64",
    ],
    deps = [":coin2_with_doctest"],
)

nazel_cc_binary(
    name = "bench",
    srcs = glob(
        [
            "bench/**/*.cc",
            "bench/**/*.h",
        ],
    ),
    defines = [
        "DOCTEST_CONFIG_NO_SHORT_MACRO_NAMES",
        "GOOGLE_STRIP_LOG=1",
    ],
    linkopts = [
        "-lcryptopp",
        "-lmkl_core",
        "-lmkl_gnu_thread",
        "-lmkl_intel_lp64",
    ],
    deps = [
        ":coin2_with_doctest",
        "//cc/third_party/nanobench",
    ],
)

compilation_database(
    name = "compdb",
    targets = [
        "//cc/coin2",
    ],
)
